let menus = [
  { id: 1, name: "整体数据" },
  { id: 2, name: "运营点数据" },
 
];
let iconList = new Map();
iconList.set("整体数据", "md-analytics");
iconList.set("运营点数据", "ios-keypad");

let menuArr = {
  getMenuArr(Menus = []) {
    let roleInfo = [];
    for (let key in menus) {
      if (Menus.includes(menus[key].id)) roleInfo.push(menus[key]);
    }
    console.log(roleInfo)
    // let _Submenu = [];
    // for (let i = 0; i < roleInfo.length; i++) {
    //   if (
    //     roleInfo[i].name != "系统配置" &&
    //     roleInfo[i].name.indexOf("-") != -1
    //   ) {
    //     let title = roleInfo[i].name.split("-")[0];
    //     _Submenu.push(title);
    //   }
    // }
    // let Submenu = Array.from(new Set(_Submenu));
    // let endSubmenu = [];
    // for (let i = 0; i < Submenu.length; i++) {
    //   let obj = {};
    //   obj.name = Submenu[i];
    //   obj.id = i;
    //   obj.icon = this.setIcon(Submenu[i]);
    //   obj.children = [];
    //   for (let j = 0; j < roleInfo.length; j++) {
    //     if (Submenu[i] == roleInfo[j].name.split("-")[0]) {
    //       obj.children.push({ name: roleInfo[j].name, id: j });
    //     }
    //   }
    //   endSubmenu.push(obj);
    // }
    // return endSubmenu;
    let endSubmenu = [];
    for (let i = 0; i < roleInfo.length; i++) {
      let obj = {};
      obj.name = roleInfo[i].name;
      obj.id = roleInfo[i].id;
      obj.icon = this.setIcon(roleInfo[i].name);
      endSubmenu.push(obj);
    }
    return endSubmenu;
  },
  setIcon(item) {
    return iconList.get(item);
  },
  systeMenu: [
    { id: 1, name: "整体数据" },
    { id: 2, name: "运营点数据" },
  ],
};

export default menuArr;
